package com.ucode.hrm.service;

import cn.hutool.core.util.ObjectUtil;
import com.ucode.hrm.mapper.HrmEmployeeCostDetailMapper;
import com.ucode.model.hrm.HrmEmployeeCostDetail;
import com.ucode.springboot.starter.mybatis.core.base.BaseService;
import com.ucode.tool.base.enums.GlobalResultCodeEnum;
import com.ucode.tool.exception.UcodeServiceException;

import java.util.List;

/**
 * 员工费用明细 Service
 * @Author: liliang
 * @Date: 2025/8/3 22:20
 * @Version: 1.0
 */
public interface HrmEmployeeCostDetailService extends BaseService<Long,HrmEmployeeCostDetail, HrmEmployeeCostDetailMapper> {

    /**
     * 批量添加
     * @param list
     * @return
     */
    public int batchInsert(List<HrmEmployeeCostDetail> list);

    /**
     * 验证是否合法并返回
     * @param id
     * @return
     */
    default HrmEmployeeCostDetail validate(Long id){
        if(ObjectUtil.isNull(id) )
            throw new UcodeServiceException(GlobalResultCodeEnum.VALIDATE_FAILED);
        //验证数据是否存在
        HrmEmployeeCostDetail brand = this.selectByPrimaryKey(id);
        if(ObjectUtil.isNull(brand) || brand.getDeltag()){
            throw new UcodeServiceException(GlobalResultCodeEnum.NO_RECORD.getCode(),"费用不存在或已删除");
        }
        return brand;
    }
}
